package com.ihr360.shared.basicstaffinfo.dto;

import com.ihr360.type.StaffStatus;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * 从员工花名册部分同步过来的部分员工数据
 */
@Entity
@Table(name = "sc_synced_basic_staff_info",indexes = {
        @Index(name = "tab_staff_info_companyId_status_mobile_idx", columnList = "companyId,staffStatus,mobileNo")})
public class SyncedBasicStaffInfo implements Serializable {

    private static final long serialVersionUID = 6626328162068389097L;

    public static final class Field {
            public final static String id = "id";
            public final static String  companyId ="companyId";
            public final static String  staffName ="staffName";
            public final static String  mobileNo ="mobileNo";
            public final static String  sex ="sex";
            public final static String  idCardType ="idCardType";
            public final static String  idCardNo="idCardNo";
            public final static String  departmentId="departmentId";
            public final static String  departmentName="departmentName";
            public final static String  staffStatus="staffStatus";
            public final static String  enrollInDate="enrollInDate";
            public final static String  lastWorkDay="lastWorkDay";

            public final static String  positionName="positionName";
            public final static String  positionId="positionId";
            public final static String  staffNo="staffNo";

        }
    @Id
    @Column(length = 40, nullable = false, unique = true)
    private String id;

    @Column(length = 40, nullable = false)
    private String companyId;
    /**
     * 姓名
     */
    @Column(length = 32)
    private String staffName;
    /**
     * 手机号
     */
    @Column(length = 18)
    private String mobileNo;
    /**
     * 性别
     */
    @Column(length = 128)
    private String sex;
    /**
     * 证件类型(直接存名称)
     */
    @Column(length = 20)
    private String idCardType;
    /**
     * 证件号
     */
    @Column(length = 30)
    private String idCardNo;

    /**
     * 部门id
     */
    private Long departmentId;

    /**
     * 部门名称
     */
    @Column(length = 128)
    private String departmentName;

    /**
     * 职位名称
     */
    @Column(length = 100)
    private String positionName;
    /**
     * 职位ID
     */
    @Column(length = 40)
    private String positionId;
    /**
     * 工号
     */
    @Column(length = 60)
    private String staffNo;

    /**
     * 入职日期
     */
    @Column(columnDefinition = "date")
    private Date enrollInDate;

    /**
     * 最后工作日
     */
    @Column(columnDefinition = "date")
    private Date lastWorkDay;

    /**
     * 员工状态（ IN_SERVICE在职，QUIT离职）
     */
    @Column(length = 10, nullable = false)
    @Enumerated(EnumType.STRING)
    private StaffStatus staffStatus = StaffStatus.IN_SERVICE;


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public String getStaffName() {
        return staffName;
    }

    public void setStaffName(String staffName) {
        this.staffName = staffName;
    }

    public String getMobileNo() {
        return mobileNo;
    }

    public void setMobileNo(String mobileNo) {
        this.mobileNo = mobileNo;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getIdCardType() {
        return idCardType;
    }

    public void setIdCardType(String idCardType) {
        this.idCardType = idCardType;
    }

    public String getIdCardNo() {
        return idCardNo;
    }

    public void setIdCardNo(String idCardNo) {
        this.idCardNo = idCardNo;
    }

    public Long getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(Long departmentId) {
        this.departmentId = departmentId;
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }

    public StaffStatus getStaffStatus() {
        return staffStatus;
    }

    public void setStaffStatus(StaffStatus staffStatus) {
        this.staffStatus = staffStatus;
    }

    public String getPositionName() {
        return positionName;
    }

    public void setPositionName(String positionName) {
        this.positionName = positionName;
    }

    public String getPositionId() {
        return positionId;
    }

    public void setPositionId(String positionId) {
        this.positionId = positionId;
    }

    public String getStaffNo() {
        return staffNo;
    }

    public void setStaffNo(String staffNo) {
        this.staffNo = staffNo;
    }

    public Date getEnrollInDate() {
        return enrollInDate;
    }

    public void setEnrollInDate(Date enrollInDate) {
        this.enrollInDate = enrollInDate;
    }

    public Date getLastWorkDay() {
        return lastWorkDay;
    }

    public void setLastWorkDay(Date lastWorkDay) {
        this.lastWorkDay = lastWorkDay;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SyncedBasicStaffInfo info = (SyncedBasicStaffInfo) o;

        if (id != null ? !id.equals(info.id) : info.id != null) return false;
        if (companyId != null ? !companyId.equals(info.companyId) : info.companyId != null) return false;
        if (staffName != null ? !staffName.equals(info.staffName) : info.staffName != null) return false;
        if (mobileNo != null ? !mobileNo.equals(info.mobileNo) : info.mobileNo != null) return false;
        if (sex != null ? !sex.equals(info.sex) : info.sex != null) return false;
        if (idCardType != null ? !idCardType.equals(info.idCardType) : info.idCardType != null) return false;
        if (idCardNo != null ? !idCardNo.equals(info.idCardNo) : info.idCardNo != null) return false;
        if (departmentId != null ? !departmentId.equals(info.departmentId) : info.departmentId != null) return false;
        if (departmentName != null ? !departmentName.equals(info.departmentName) : info.departmentName != null)
            return false;
        if (positionName != null ? !positionName.equals(info.positionName) : info.positionName != null) return false;
        if (positionId != null ? !positionId.equals(info.positionId) : info.positionId != null) return false;
        if (staffNo != null ? !staffNo.equals(info.staffNo) : info.staffNo != null) return false;
        if (enrollInDate != null ? !enrollInDate.equals(info.enrollInDate) : info.enrollInDate != null) return false;
        if (lastWorkDay != null ? !lastWorkDay.equals(info.lastWorkDay) : info.lastWorkDay != null) return false;
        return staffStatus == info.staffStatus;

    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (companyId != null ? companyId.hashCode() : 0);
        result = 31 * result + (staffName != null ? staffName.hashCode() : 0);
        result = 31 * result + (mobileNo != null ? mobileNo.hashCode() : 0);
        result = 31 * result + (sex != null ? sex.hashCode() : 0);
        result = 31 * result + (idCardType != null ? idCardType.hashCode() : 0);
        result = 31 * result + (idCardNo != null ? idCardNo.hashCode() : 0);
        result = 31 * result + (departmentId != null ? departmentId.hashCode() : 0);
        result = 31 * result + (departmentName != null ? departmentName.hashCode() : 0);
        result = 31 * result + (positionName != null ? positionName.hashCode() : 0);
        result = 31 * result + (positionId != null ? positionId.hashCode() : 0);
        result = 31 * result + (staffNo != null ? staffNo.hashCode() : 0);
        result = 31 * result + (enrollInDate != null ? enrollInDate.hashCode() : 0);
        result = 31 * result + (lastWorkDay != null ? lastWorkDay.hashCode() : 0);
        result = 31 * result + (staffStatus != null ? staffStatus.hashCode() : 0);
        return result;
    }
}